import axios from 'axios'

export const baseUrl = 'http://localhost:9000'
axios.defaults.withCredentials = true;
axios.defaults.changeOrigin = true;
export function request (config) {
  const instance = axios.create({
    baseURL: baseUrl,
    timeout: 5000,
    headers: {}
  })

  // 拦截器
  instance.interceptors.response.use(res => {
    // setTimeout(() => {
    //
    // }, 2000)
    console.log(res)
    return res.data
  }, error => {
    console.log(error)
    // 登录失效
    return error
  })
  return instance(config)
}
